<?php defined('SYSPATH') or die('No direct script access.');

class Model_Usuario extends ORM {

	public function exists()
	{
		return ORM::factory('usuario')
			->where('usuario', '=', $this->usuario)
			->find()->loaded();
	}
	
	public $_belongs_to = array();
	
	public $_has_one = array();
	
	public $_has_many = array(
		'permissoes' => array(
			'model' => 'permissao',
			'foreign_key' => 'usuario_id',
			'through' => 'permissoes_usuarios'
		),
		'reservas' => array(
			'model' => 'reserva',
			'foreign_key' => 'usuario_id'
		),
	);
	
	public $_table_name = 'usuarios';
	public $_primary_key = 'id';
	
} // End Usuario
